class cookies {
    constructor(cookiesStr) {
        this._cookies = Object.create(null);
        cookiesStr && cookiesStr.split(';').forEach(cookie => {
            var parts = cookie.split('=');
            this._cookies[parts[0].trim()] = (parts[1] || '').trim();
        });
    }

    get(key) {
        return this._cookies[key] || null;
    }

    getAll() {
        return this._cookies;
    }

    isNull() {
        return Object.keys(this._cookies).length == 0;
    }
}

module.exports = cookies;